使用方法1
2
3
4
5
6
7
8
9
10
11在Application里初始化
this.mRefWatcher = BuildConfig.DEBUG ? LeakCanary.install(this) : RefWatcher.DISABLED;
fragment的onDestroy
public void onDestroy() {
super.onDestroy();
RefWatcher refWatcher = App.getMyApplicationContext().getRefWatcher();
refWatcher.watch(this);
}
简述:install
的时候为application
注册Application.ActivityLifecycleCallbacks
,然后在onActivityDestroyed
为当前activity
添加弱引用,手动触发gc
,收集日志然后报警与否。